<?php

use yii\db\Migration;

class m180613_082738_alter_customer_relationship extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%customer_relationship}}', 'admin_child_ids', $this->string(255)->defaultValue(null)->comment('副负责人'));
            $this->addColumn('{{%customer_relationship}}', 'salesman_id', $this->integer(11)->defaultValue(0)->comment('跟进负责人'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%customer_relationship}}', 'admin_child_ids');
            $this->dropColumn('{{%customer_relationship}}', 'salesman_id');
        }
    }
}
